from appium import webdriver
from appium.webdriver.common.appiumby import By
from time import sleep

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7'
desired_caps['deviceName'] = '127.0.0.1:62001'
desired_caps['app'] = r'D:\android\apk\mymoney.apk'
desired_caps['appPackage'] = 'com.mymoney'
desired_caps['appActivity'] = 'com.mymoney.biz.splash.SplashScreenActivity'
desired_caps['noReset'] = False

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
driver.implicitly_wait(10)
sleep(3)

# 点击 同意
try:
    ele = driver.find_element(By.ID, 'com.mymoney:id/sui_dialog_positive_btn_style1')
except Exception as e:
    print('no agreeBtn')
else:
    ele.click()

# 点击 选账本
try:
    ele = driver.find_element(By.ID, 'com.mymoney:id/select_template_btn')
except Exception as e:
    print('no selectBtn')
else:
    ele.click()

# 点击 跳过
try:
    ele = driver.find_element(By.ID, 'com.mymoney:id/bottom_skip_tv')
except Exception as e:
    print('no skipBtn')
else:
    ele.click()

sleep(3)